<?php


namespace App\Transformers\User;

use App\Models\UserAddress;
use League\Fractal\TransformerAbstract;

class UserAddressTransformer extends TransformerAbstract
{
    public function transform(UserAddress $userAddress)
    {
        return [
            'id'=>$userAddress->id,
            'user_id'=>$userAddress->user_id ?? '',
            'consignee_name'=>$userAddress->consignee_name ?? '',
            'phone'=>$userAddress->phone ?? '',
            'province'=>$userAddress->province ?? '',
            'city'=>$userAddress->city ?? '',
            'district'=>$userAddress->district ?? '',
            'city_id'=>$userAddress->city_id ?? '',
            'detail'=>$userAddress->detail ?? '',
            'post_code'=>$userAddress->post_code ?? '',
            'longitude'=>$userAddress->longitude ?? '',
            'latitude'=>$userAddress->latitude ?? '',
            'is_default'=>$userAddress->is_default ?? 0,
            'deleted_at'=>$userAddress->deleted_at ?? '',
            'created_at' => $userAddress->created_at ? $userAddress->created_at->format("Y-m-d H:i:s") : '',
            'updated_at' => $userAddress->updated_at ? $userAddress->updated_at->format("Y-m-d H:i:s") : '',
        ];
    }
}
